{include file="public/header" /}
<style type="text/css">
	.float-e-margins .btn{margin: 0!important;}
	.laydate-icon{background-image: none!important;}
	.choose_time{width: 80px;}
	td i{font-style: normal;}
	td img{cursor:pointer;width: 8rem;}
</style>
<body class="gray-bg">
<div class="wrapper wrapper-content animated fadeInRight">
    <!-- Panel Other -->
    <div class="ibox float-e-margins">
        <div class="ibox-title">
            <h5>申请成为业主列表</h5>
        </div>
        <div class="ibox-content">
            <!--搜索框开始-->           
            <div class="row">
	                <form name="users" class="form-search form-inline" method="post" action="{:url('')}">
						<div class="col-md-2">
							<div class="form-group">
						        <input class="form-control" type="text" name="phone" value="{if !empty($phone)}{$phone}{/if}"  placeholder="手机号模糊查询">
							</div>
						</div>
						<div class="col-sm-3">
                        	<div class="input-group">
				        		<span class="input-group-btn"><i class="btn btn-primary" style="font-style: normal;">状态：</i></span>
	                                <select class="form-control m-b" name="stat">
	                                 	<option value="">--选择状态--</option>
	                                 	<option value="1">待处理</option>
	                                 	<option value="2">通过</option>
	                                 	<option value="3">驳回</option>
                                 	</select>
							</div>
						</div>
						<div class="col-md-2">
							<div class="form-group">
						        <input class="form-control choose_time" type="text" name="stime" value="{if input('stime')!=0}{:input('stime')}{/if}"  placeholder="创建开始时间">
							</div>
						</div>
	                	<div class="col-md-2">
	                		<div class="form-group">
						        <input class="form-control choose_time" type="text" name="etime" value="{if input('etime')!=0}{:input('etime')}{/if}"  placeholder="创建结束时间">
	                       </div>
	                	</div>
						<div class="col-md-1">
							<div class="form-group">
								<button class="btn btn-outline btn-primary" type="submit">
									<i class="fa fa-search"></i>搜索
								</button>
							</div>
						</div>
					  	<div class="col-md-1">
					  		<div class="form-group">
								<button class="btn btn-outline btn-primary" type="button"  onClick="export_excel();">导出数据</button>
							</div>
					  	</div>
	              </form>
            </div>
            <!--搜索框结束-->
            <div class="hr-line-dashed"></div>
            <div class="example-wrap">
                <div class="example">
                    <table class="table table-bordered table-hover">
                        <thead>
                            <tr class="long-tr">
                            	<th>名称</th>
                            	<th>昵称</th>
                            	<th>头像</th>
                            	<th>手机号</th>
                            	<th>身份证</th>
                            	<th>身份</th>
                            	<th>操作</th>
                            </tr>
                        </thead>
                        <tbody>
                    		{volist name="data" id="item" empty="$empty"}
                        	<tr class="long-td">
                        		<td>{$item.name}</td>
                        		<td>{$item.nickname}</td>
                        		<td><img style="width:65px;height:55px" class="img-thumbnail" onerror="this.src='/static/admin/images/head_default.gif'" src="{$item.head_img}"/></td>
                        		<td>{$item.phone}</td>
                        		<td>
                        			<a href="javascript:;" onclick='show_img("{$item.idcard_img_a}")'>{$item.idcard}</a>
                        		</td>
                        		<td>
                        			{switch name="$item.stat" }
									{case value="1" break="1"}待处理{/case}
									{case value="2" break="1"} <i style="color: green;">通过</i> {/case}
									{case value="3" break="1"} <i style="color: red;">驳回</i> {/case}
									{default /}未知状态
									{/switch}
                        		</td>
                        		<td>
                    			{if $item.stat==1}
                        			<a href="javascript:;" onclick='check_apply_ower({$item.id})' class="btn btn-primary btn-outline btn-xs">
                        				<i class="fa fa-filter"></i> 处理</a>&nbsp;&nbsp;
                        			</a>
                    			{/if}
                                    <a href="javascript:;" onclick="del({$item.id})" class="btn btn-danger btn-outline btn-xs">
                                        <i class="fa fa-trash-o"></i> 删除</a>
                        		</td>
                        		
                        	</tr>
                        	{/volist}
                        </tbody>
                    </table>
                    <div style="text-align: right;">{$page}</div>
                </div>
            </div>
            <!-- End Example Pagination -->
        </div>
    </div>
</div>
<!-- End Panel Other -->
</div>
{include file="public/footer" /}

<script type="text/javascript">
	stat="{$stat}";
	var stime   ="{:input('stime')}";
	if(stime.length<=0){
		stime=0;
	}
	var etime   ="{:input('etime')}";
	if(etime.length<=0){
		etime=0;
	}
	$(document).ready(function(){	
		lay('.choose_time').each(function(){
		  laydate.render({
		    elem: this,
		    trigger: 'click'
		  });
		});
 	});
 	$('select[name="stat"] option').each(function(){
   		if($(this).val()==stat) $(this).attr('selected','selected');
   	});
   	$('img').on('click',function(){
   		var path=$(this).attr('src');
   		show_img(path);
   	});
   	function check_apply_ower(id){
   		layer.open({
		  content: '处理该申请',
		  btn: ['通过', '驳回'],
		  yes: function(index, layero){
		  	update_val(id,2);
		  },
		  btn2: function(index, layero){
		  	update_val(id,3);
		  }
		});
   	}
   	function update_val(id,val){
   		$.getJSON('{:url("do_apply")}', {"id":id,"val":val}, function(res){
            if(res.code == 1){
                layer.msg(res.msg,{icon:1,time:1500,shade: 0.1},function(){
              	window.location.reload();	
                });
            }else{
                layer.msg(res.msg,{icon:0,time:3000,shade: 0.1});
            }
        });
   	}
   	function show_img(path){
   		layer.open({
			type:1,
			title:false,
			shadeClose:true,
			closeBtn:0,
			content:"<img class='img-thumbnail' src='"+path+"'>"
		});
   	}
 	//导出数据
// 	function export_excel(){
// 		window.location.href="{:url('Export/export_use_tag')}?status="+status+"&co_id="+co_id+"&stime="+stime+"&etime="+etime
// 	}
//展示程序数据
//function showprogram(nid){
//  location.href = './showprogram/nid/'+nid+'.html';
//}
//审核准租客
function check_idcard(id){
	layer.confirm('确认通过身份验证吗?', {icon: 3, title:'提示'}, function(index){
        $.getJSON('{:url("index/update_val")}', {'tab':'users','idname':'id','id':id,'key':'type','val':2 }, function(res){
            if(res.code == 1){
                layer.msg(res.msg,{icon:1,time:1500,shade: 0.1},function(){
              	window.location.reload();	
                });
            }else{
                layer.msg(res.msg,{icon:0,time:3000,shade: 0.1});
            }
        });
        layer.close(index);
    })
//	layer.open({
//		type:2,
//		title:false,
//		closeBtn:false,
//		shadeClose:true,
//		area: ['400px', '660px'],
//		content:"{:url('show_goods')}?id="+id
//	});
}
//查看点评
function remark(id,goods_name){
	location.href = "{:url('remark')}?goods_id="+id+"&goods_name="+goods_name;
}
//编辑程序
function edit(id){
    location.href = "{:url('edit_goods')}?goods_id="+id;
}
//
//更改VIP是否收费
function change_stat(_this,id,key){
    lunhui.change_stat(_this,'users','id',id,key,'{:url("index/change_stat")}');
}
//删除
function del(id){
    lunhui.del('users','id',id,'del','{:url("index/del")}');
}
</script>
</body>
</html>